import java.awt.*;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MyDrawPanel3 extends JPanel{
	
	public void paintComponent(Graphics g){
		g.setColor(Color.black);
		g.fillRect(0, 0, this.getWidth(),this.getHeight() );
		
		Graphics2D g2d=(Graphics2D) g;
		
		int red=(int)(Math.random()*255);
		int green=(int)(Math.random()*255);
		int blue=(int)(Math.random()*255);
		Color startColor=new Color(red,green,blue);
		
		red=(int)(Math.random()*255);
		green=(int)(Math.random()*255);
		blue=(int)(Math.random()*255);
		Color endColor=new Color(red,green,blue);
		
		GradientPaint gradient=new GradientPaint(70,70,startColor,150,150,endColor);
		g2d.setPaint(gradient);
		g2d.fillRect(70, 70, 100, 100);
	}
	
public static void main(String[] args){
		
		JFrame frame=new JFrame();
		
		MyDrawPanel3 panel=new MyDrawPanel3();
		
		frame.getContentPane().add(panel);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(1000,1000);
		frame.setVisible(true);
		
	}

}
